<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <%@ include file="/WEB-INF/jsp/common/js.jsp"%>

    <style>
        .shortInput{
            width: 500px;
        }
    </style>
    <script>
        $(document).ready(function(){
            //如果是新建
            if($('#urlid').val()==''){
                $('#pid').val($('#urlpid').val());
                var url = '<%=request.getContextPath()%>/devops/menu/orderNum?pid='+$('#pid').val();
                JSendAjax(url);
            }

            //如果是一级菜单则隐藏
            if($('#pid').val()=='-1'){
                $('#divUrl').hide();
            }
        });

        function JCollBack(_data){
            if(_data.success){
                $('#orderNun').val(_data.data);
                return;
            }
            alert(_data.msg);
        }
    </script>
</head>
<body>
<div class="container">
    <h1>菜单</h1>
    <input name="urlpid" id="urlpid" value="<%=StringUtils.trimToEmpty(request.getParameter("pid")) %>" type="hidden">
    <input name="urlid" id="urlid" value="<%=StringUtils.trimToEmpty(request.getParameter("id")) %>"type="hidden">
    <div id="divDefualtForm">
        <form method="post" action="${pageContext.request.contextPath}/devops/menu/update">
            <div class="form-group" style="display: none">
                <label for="id">id</label>
                <input name="id" id="id" type="text" class="form-control shortInput" placeholder="" value="${po.id}">
            </div>
            <div class="form-group">
                <label>父节点</label>
                <input name="pid" id="pid" type="text" class="form-control shortInput" placeholder="" value="${po.pid}" readOnly></input>
            </div>
            <div class="form-group">
                <label>名称</label>
                <input name="name" id="name" type="text" class="form-control shortInput" placeholder="" value="${po.name}">
            </div>
            <div class="form-group" id="divUrl">
                <label>URL</label>
                <input name="url" id="url" type="text" class="form-control shortInput" placeholder=""  value="${po.url}">
            </div>
            <div class="form-group">
                <label>描述</label>
                <input name="description" id="description" type="text" class="form-control shortInput" placeholder=""  value="${po.description}">
            </div>
            <div class="form-group">
                <label>排序号</label>
                <input name="orderNun" id="orderNun" type="text" class="form-control shortInput" placeholder="只能输入数字，例:1"  onkeyup='this.value=this.value.replace(/\D/gi,"")' value="${po.orderNun}">
            </div>
            <div class="form-group">
                <label></label>
                <button type="submit" class="btn btn-default">保存</button>
                <button type="reset" class="btn btn-default">重置</button>
                <button id="btnGoBack" type="button" class="btn btn-default">返回</button>
            </div>
        </form>
    </div>
</div>
</body>
</html>
